package com.hxgz.steel;

import com.hxgz.steel.common.sdk.SDKConfig;
import javax.servlet.MultipartConfigElement;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.MultipartConfigFactory;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.context.annotation.Bean;
import org.springframework.scheduling.annotation.EnableScheduling;

@SpringBootApplication
@MapperScan(basePackages = "com.hxgz.steel.dao")
@EnableScheduling
public class SteelApplication extends SpringBootServletInitializer {

  public static void main(String[] args) {
    SpringApplication.run(SteelApplication.class, args);
    SDKConfig.getConfig().loadPropertiesFromSrc();
  }

  @Override//为了打包springboot项目
  protected SpringApplicationBuilder configure(
      SpringApplicationBuilder builder) {
    return builder.sources(this.getClass());
  }


  /**
   * 文件上传配置
   */
  @Bean
  public MultipartConfigElement multipartConfigElement() {
    MultipartConfigFactory factory = new MultipartConfigFactory();
    //文件最大
    factory.setMaxFileSize("10240KB"); //KB,MB
    /// 设置总上传数据总大小
    factory.setMaxRequestSize("102400KB");
    return factory.createMultipartConfig();
  }

}

